{template "topic_header"}
<div class="bind_wrap">
    <h3 class="bind_title">开心帐号绑定</h3>
    <div class="bind_nav Menubox">
    	<ul>
    	   <li><div id="kaixin_div_0" class="tagcurrent"><a onclick="kaixin_switch_div(0);return false;" href="javascript:void(0)"><span>注册新帐户</span></a></div></li>
    	   <li><div id="kaixin_div_1" class="tagn"><a onclick="kaixin_switch_div(1);return false;" href="javascript:void(0)"><span>绑定已有的帐号</span></a></div></li>
    	</ul>
	</div>
    <script language="javascript">
        function kaixin_switch_div(ss)
        {
            var ss = ('undefined'==typeof(ss) ? 0 : ss);
            
            if(ss)
            {
                $('#kaixin_div_0').attr('class','tagn');
                $('#kaixin_div_1').attr('class','tagcurrent');
                $('#kaixin_user_reg').css('display','none');
                $('#kaixin_user_login').css('display','block');
            }
            else
            {                
                $('#kaixin_div_0').attr('class','tagcurrent');
                $('#kaixin_div_1').attr('class','tagn');
                $('#kaixin_user_reg').css('display','block');
                $('#kaixin_user_login').css('display','none');
            }
            
            return false;            
        }
        var reg_submit = false;
        function kaixin_user_reg_check()
        {
        	if(true == reg_submit) return ;
        	
            var reg_nickname = $('#reg_nickname').val();
            var reg_email = $('#reg_email').val();
            var reg_password = $('#reg_password').val();           
            
            var myAjax = $.post
            (
                'index.php?mod=kaixin&code=reg_check&in_ajax=1',
                {
                    nickname:reg_nickname,
                    email:reg_email,
                    password:reg_password
                },
                function(d)
                {
                    if(d)
                    {
                    	reg_submit = false;
                        alert(d);
                    }
                    else
                    {
                    	reg_submit = true;
                        if(true == reg_submit) {
                        	$('#kaixin_user_reg_form').submit();
                        	return true;
                        }                        
                    }
                }
            );
            
            return false;
        }
        var login_submit = false;
        function kaixin_user_login_check()
        {
        	if(true == login_submit) return ;
        	
            var login_username = $('#login_username').val();
            var login_password = $('#login_password').val();
            
            var myAjax = $.post
            (
                'index.php?mod=kaixin&code=login_check&in_ajax=1',
                {
                    username:login_username,
                    password:login_password
                },
                function(d)
                {
                    if(d)
                    {
                    	login_submit = false;
                        alert(d);
                    }
                    else
                    {
                    	login_submit = true;
                    	if(true == login_submit) {
	                        $('#kaixin_user_login_form').submit();
	                        return true;
                    	}
                    }
                }
            );
            
            return false;
        }
    </script>
     <div class="bind_con"> 
        <div id="kaixin_user_reg" style="display: block;">
			<!--{eval $regstatus = jsg_member_register_check_status();}-->
            <!--{if $regstatus['error'] || (true!==JISHIGOU_FORCED_REGISTER && $regstatus['invite_enable'] && !$regstatus['normal_enable'])}-->
            
                非常抱歉，本站目前不支持绑定新注册用户；<a onclick="kaixin_switch_div(1);return false;" href="javascript:void(0)"><span><strong>请点此绑定已有的帐号</strong></span></a>
                
            <!--{else}-->            
                
        	<form id="kaixin_user_reg_form" name="kaixin_user_reg_form" method="POST" action="index.php?mod=kaixin&code=do_reg" onsubmit="return kaixin_user_reg_check();">
        		<input type="hidden" name="hash" value="{$hash}" />        		
                <!--{loop $bind_info $k $v}-->
            	<input type="hidden" name="bind_info[{$k}]" value="{$v}" />
            	<!--{/loop}-->
            	<table width="100%" border="0">
                  <tr>
            	    <td colspan="2">            
            	       <div class="tagg2">新注册的帐号将会与开心帐号绑定</div>
           	        </td>
            	  </tr>
            	  <tr>
            	    <td width="15%" align="right" valign="top">帐户/昵称：</td>
            	    <td><input id="reg_nickname" name="nickname" type="text"  class="p1"  value="{$reg[nickname]}" />
            		（用于登录、显示、@通知和发送站内信）
            		</td>
            	  </tr>
            	  <tr>
            	    <td align="right" valign="top">Email 邮箱：</td>
            	    <td><input id="reg_email" name="email" type="text" value="{$reg[email]}" class="p1" />
            		（用于登录、提醒和取回密码）
            		</td>
            	  </tr>
                  <tr>
            	    <td align="right" valign="top">登录密码：</td>
            	    <td><input id="reg_password" name="password" type="password" value="" class="p1" />
            		</td>
            	  </tr>          
            	  <tr>
            	    <td align="right" valign="top">&nbsp;</td>
            	    <td><input type="submit" class="u-btn" value="注 册"/></td>
            	  </tr>
            	</table>
            </form>
            
            <!--{/if}-->
            
        </div>        
        <div id="kaixin_user_login" style="display: none;">
            <form id="kaixin_user_login_form" name="kaixin_user_login_form" method="POST" name="profile_base" action="index.php?mod=kaixin&code=do_login" onsubmit="return kaixin_user_login_check();">
            	<input type="hidden" name="hash" value="{$hash}" />        		
                <!--{loop $bind_info $k $v}-->
            	<input type="hidden" name="bind_info[{$k}]" value="{$v}" />
            	<!--{/loop}-->
            	<table width="100%" border="0">
                  <tr>
            	    <td colspan="2">            
            	       <div class="tagg2">登录的帐号将会与开心帐号绑定</div>
           	        </td>
            	  </tr>
            	  <tr>
            	    <td width="13%" align="right" valign="top">帐户/昵称：</td>
            	    <td><input id="login_username" name="username" type="text" value="" class="p1" />
            		</td>
            	  </tr>
                  <tr>
            	    <td align="right" valign="top">登录密码：</td>
            	    <td><input id="login_password" name="password" type="password" value="" class="p1" />
            		</td>
            	  </tr>          
            	  <tr>
            	    <td align="right" valign="top">&nbsp;</td>
            	    <td><input type="submit" class="u-btn" value="登 录"/></td>
            	  </tr>
            	</table>
            </form>
        </div>
    </div>
</div>
</div></div>
{template "topic_footer"}